class ArticlePreview < ActiveRecord::Base
  include TruncateHtmlHelper

  belongs_to :article

  def doc=(doc)
    doc.css('img').remove
    self.body = truncate_html(doc.css('body').inner_html, length: 450, omission: '...', break_token: '<!-- truncate -->')
  end
end
